﻿using UnityEngine;
using System.Collections;

public class reportController : MonoBehaviour {

	private int reports;
	private int state;
	public AudioSource src;
	public AudioSource src2;
	public AudioSource argue1;
	public AudioSource argue2;
	public GameObject player;
	public GameObject obj1;
	public GameObject obj2;
	public AudioClip clip1;
	public AudioClip clip2;


	// Use this for initialization
	void Start () {
		reports = 0;
		state = 0;
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown("r"))
		{
			reports = reports + 1;
			src.Stop();
			src.audio.pitch = Mathf.Pow (1.06f,reports);
			src.Play();
		}
		else if (Input.GetKeyDown("t") && reports > 0 && state == 0)
		{
			reports = reports - 1;
			if (reports < 0) reports = 0;
			state = 1;
			argue1.audio.clip = clip1;
			argue1.audio.loop = true;
			argue1.Play();
			argue2.Play();
			src2.Play();

		}
//
		if (state == 1)
		{
			float d = Vector3.Distance(player.transform.position, obj1.transform.position);
			src2.audio.pitch = 2-(d/75);
			if (d < 4)
			{
				argue1.audio.clip = clip2;
				argue1.audio.loop = false;
				argue1.Play();
				argue2.Stop();
				state=0;
				src2.Stop();
			}
		}
	}
}
